package com.example.libraryapp.adapter;

import android.content.Context;

import com.example.libraryapp.R;
import com.example.libraryapp.adapter.base.BaseAdapter;
import com.example.libraryapp.adapter.base.BaseViewHolder;
import com.example.libraryapp.bean.BookBorrow;
import com.example.libraryapp.util.GlideUtil;

/**
 * @author 伍凯铭
 * @since 2020/6/28
 */
public class BorrowHistoryAdapter extends BaseAdapter<BookBorrow> {

    public BorrowHistoryAdapter(Context context) {
        super(context);
    }

    @Override
    public void bindData(BaseViewHolder holder, BookBorrow data) {
        GlideUtil.loadImage(mContext,data.getBook().getPicture(),holder.getImageView(R.id.book_img));
        holder.getTextView(R.id.book_name).setText(data.getBook().getBookName());
        holder.getTextView(R.id.book_borrow_start).setText(String.format(mContext.getResources().getString(R.string.borrow_start),data.getBorrowDate()));
        holder.getTextView(R.id.book_borrow_ddl).setText(String.format(mContext.getResources().getString(R.string.return_date),data.getReturnDate()));
        holder.itemView.setOnClickListener(holder);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_book_borrow;
    }
}
